<template>
  <div class="about-container">
    <!-- 主要内容区域 -->
    <div class="main-content">
      <el-card class="info-card">
        <div class="hotel-banner">
          <div class="banner-overlay">
            <h1>关于{{ websiteInfo.name }}</h1>
            <p>为您提供舒适优雅的住宿体验</p>
          </div>
        </div>

        <!-- 酒店信息展示 -->
        <div v-if="websiteInfo" class="hotel-info">
          <h2>{{ websiteInfo.name }}</h2>
          <p class="description">{{ websiteInfo.description }}</p>
          
          <el-divider />
          
          <div class="contact-section">
            <div class="contact-item">
              <i class="el-icon-phone"></i>
              <div>
                <h3>联系电话</h3>
                <p>{{ websiteInfo.contactPhone }}</p>
              </div>
            </div>
            
            <div class="contact-item">
              <i class="el-icon-message"></i>
              <div>
                <h3>联系邮箱</h3>
                <p>{{ websiteInfo.contactEmail }}</p>
              </div>
            </div>
            
            <div class="contact-item">
              <i class="el-icon-location-information"></i>
              <div>
                <h3>酒店地址</h3>
                <p>{{ websiteInfo.address }}</p>
              </div>
            </div>
            
            <div class="contact-item">
              <i class="el-icon-time"></i>
              <div>
                <h3>营业时间</h3>
                <p>{{ websiteInfo.businessHours }}</p>
              </div>
            </div>
          </div>
          
          <el-divider />
          
          <div class="map-section">
            <h3>酒店位置</h3>
            <div class="map-placeholder">
              <!-- 这里可以替换为真实的地图组件 -->
              <div class="map-mock">
                <i class="el-icon-location"></i>
                <p>{{ websiteInfo.address }}</p>
              </div>
            </div>
          </div>
        </div>
        
        <div v-else class="loading-section">
          <el-skeleton :rows="5" animated />
        </div>
      </el-card>
    </div>

    <!-- 页脚 -->
    <el-footer class="footer">
      <div class="footer-content">
        <div class="footer-logo">{{ websiteInfo.name }}</div>
        <div class="footer-links">
          <p>© 2025 {{ websiteInfo.name }} 版权所有</p>
          <p>京ICP备12345678号</p>
        </div>
      </div>
    </el-footer>
  </div>
</template>

<script>
import { getToken } from '@/utils/auth'; // 导入身份验证方法
import { getWebsiteinfo } from '@/api/Websiteinfo.js'; // 导入获取网站信息的API

export default {
  name: 'AboutPage',
  data() {
    return {
      activeMenu: '/about',
      isLoggedIn: false,
      websiteInfo: null
    };
  },
  mounted() {
    // 检查登录状态
    this.checkLoginStatus();
    // 获取网站信息
    this.fetchWebsiteInfo();
  },
  methods: {
    // 检查用户登录状态
    checkLoginStatus() {
      const token = getToken();
      this.isLoggedIn = !!token;
      
      // 如果未登录，则跳转到登录页面
      if (!token) {
        this.$router.push('/login');
      }
    },
    
    // 从API获取网站信息
    async fetchWebsiteInfo() {
      try {
        // 获取ID为1的网站信息
        const response = await getWebsiteinfo(1);
        
        // 检查响应是否成功
        if (response.code === 200) {
          this.websiteInfo = response.data;
        } else {
          this.$message.error('获取网站信息失败');
        }
      } catch (error) {
        console.error('获取网站信息时出错:', error);
        this.$message.error('获取网站信息时出错');
      }
    }
  }
};
</script>

<style scoped>
.about-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: #f8f9fa;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #fff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  padding: 0 8%;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.logo {
  font-size: 24px;
  font-weight: bold;
  color: #2c3e50;
  letter-spacing: 1px;
}

.el-menu {
  border-bottom: none;
}

.el-menu-item {
  font-size: 16px;
  font-weight: 500;
  padding: 0 20px;
}

.el-menu-item.active {
  color: #409EFF;
  border-bottom: 2px solid #409EFF;
}

.main-content {
  flex: 1;
  max-width: 1200px;
  width: 90%;
  margin: 30px auto;
  padding: 0 15px;
}

.info-card {
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.hotel-banner {
  height: 300px;
  background: linear-gradient(rgba(0, 0, 0, 0.4)) center/cover;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  text-align: center;
}

.banner-overlay h1 {
  font-size: 3rem;
  margin-bottom: 15px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.banner-overlay p {
  font-size: 1.5rem;
  opacity: 0.9;
}

.hotel-info {
  padding: 30px;
}

.hotel-info h2 {
  text-align: center;
  color: #2c3e50;
  font-size: 2rem;
  margin-bottom: 20px;
}

.description {
  font-size: 18px;
  line-height: 1.8;
  color: #555;
  text-align: center;
  margin-bottom: 30px;
}

.contact-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 25px;
  margin: 30px 0;
}

.contact-item {
  display: flex;
  align-items: flex-start;
  gap: 15px;
  padding: 15px;
  background: #f8f9fa;
  border-radius: 8px;
  transition: transform 0.3s;
}

.contact-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.contact-item i {
  font-size: 28px;
  color: #409EFF;
}

.contact-item h3 {
  margin: 0 0 8px 0;
  color: #2c3e50;
}

.contact-item p {
  margin: 0;
  color: #666;
  font-size: 16px;
}

.map-section {
  margin-top: 30px;
}

.map-placeholder {
  height: 300px;
  background: #f0f2f5;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 15px;
}

.map-mock {
  text-align: center;
  color: #666;
}

.map-mock i {
  font-size: 60px;
  color: #409EFF;
  margin-bottom: 15px;
}

.footer {
  background: #2c3e50;
  color: white;
  padding: 30px 0;
  margin-top: 50px;
}

.footer-content {
  max-width: 1200px;
  width: 90%;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-logo {
  font-size: 22px;
  font-weight: bold;
}

.footer-links p {
  margin: 5px 0;
  text-align: right;
  color: #ddd;
  font-size: 14px;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .header {
    padding: 0 20px;
    flex-direction: column;
    height: auto;
    padding: 10px 0;
  }
  
  .logo {
    margin-bottom: 10px;
  }
  
  .contact-section {
    grid-template-columns: 1fr;
  }
  
  .footer-content {
    flex-direction: column;
    text-align: center;
  }
  
  .footer-links p {
    text-align: center;
  }
}
</style>